namespace Beauty.Net.JsonWebToken.Core;

/// <summary>
/// JWT服务接口
/// </summary>
public interface IJwtService
{
    /// <summary>
    /// 创建访问令牌
    /// </summary>
    /// <param name="userId">用户ID</param>
    /// <param name="claims">自定义声明</param>
    /// <returns>访问令牌</returns>
    string CreateAccessToken(string userId, Dictionary<string, object>? claims = null);
    
    /// <summary>
    /// 创建刷新令牌
    /// </summary>
    /// <param name="userId">用户ID</param>
    /// <returns>刷新令牌</returns>
    string CreateRefreshToken(string userId);
    
    /// <summary>
    /// 验证访问令牌
    /// </summary>
    /// <param name="token">访问令牌</param>
    /// <returns>验证结果</returns>
    (bool IsValid, string? UserId, Dictionary<string, object>? Claims) ValidateAccessToken(string token);
    
    /// <summary>
    /// 验证刷新令牌
    /// </summary>
    /// <param name="token">刷新令牌</param>
    /// <returns>验证结果</returns>
    (bool IsValid, string? UserId) ValidateRefreshToken(string token);
    
    /// <summary>
    /// 刷新访问令牌
    /// </summary>
    /// <param name="refreshToken">刷新令牌</param>
    /// <returns>新的访问令牌</returns>
    string? RefreshAccessToken(string refreshToken);
    
    /// <summary>
    /// 检查令牌是否即将过期
    /// </summary>
    /// <param name="token">访问令牌</param>
    /// <param name="minutesThreshold">过期阈值（分钟）</param>
    /// <returns>是否即将过期</returns>
    bool IsTokenExpiringSoon(string token, int minutesThreshold = 5);
}